<template>
  <el-badge v-if="show" class="mark mark-nb-table" :value="badge.name" />
</template>

<script>
  import {Badge} from 'element-ui'
  export default {
    data () {
      return {}
    },
    props: {
      badge: Object,
      row: Object
    },
    components: {
      ElBadge: Badge
    },
    computed: {
      show () {
        if (!this.badge) {
          return false
        }
        if (this.badge.hasOwnProperty('type') && this.badge.type === 'customer') {
          return (this.row[this.badge.key] === this.badge.value) || ((this.row[this.badge.key1] === this.badge.value1) && (this.row[this.badge.key2] === this.badge.value2))
        } else if (this.badge.and) {
          if (this.badge.key1) {
            return ((this.row[this.badge.key1] === this.badge.value1) || (this.row[this.badge.key] === this.badge.value)) && (this.row[this.badge.and.key] === this.badge.and.value)
          } else {
            return (this.row[this.badge.key] === this.badge.value) && (this.row[this.badge.and.key] === this.badge.and.value)
          }
        } else {
          if (this.badge.key1) {
            return (this.row[this.badge.key1] === this.badge.value1) || (this.row[this.badge.key] === this.badge.value)
          } else {
            return (this.row[this.badge.key] === this.badge.value)
          }
        }
      }
    },
    methods: {},
    mounted () {
    }
  }
</script>

<style lang="scss">

</style>
